package model.inventory;
// Generated Oct 27, 2012 8:43:23 AM by Hibernate Tools 3.2.1.GA


import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * MstItemBonus generated by hbm2java
 */
@Entity
@Table(name="mst_item_bonus",schema="inventory")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class ItemBonus  implements java.io.Serializable {

    private ItemBonusId id;
    private ItemHpp itemHpp;
    private Hadiah hadiah;
    private String satuanBonus;
    private String caraHitung;
    private Integer batas = 0;
    private Integer bonus = 0;
    private String jenisBonus;
    private Date beginDate;
    private Date endDate;

    public ItemBonus() {
        this.id = new ItemBonusId();
        this.beginDate = new Date();
        this.endDate = new Date();
        this.caraHitung = utility.typeSafe.HitungBonus.MULTIPLY.toString();
        this.satuanBonus = utility.typeSafe.SatuanBonus.IN_CTN.toString();
        this.jenisBonus = utility.typeSafe.JenisBonus.BPB.toString();
    }
           
    @EmbeddedId
    @AttributeOverrides( {
        @AttributeOverride(name="itemId", column=@Column(name="item_id", nullable=false) ), 
        @AttributeOverride(name="startDate", column=@Column(name="start_date", nullable=false, length=13) ), 
        @AttributeOverride(name="supplierId", column=@Column(name="supplier_id", nullable=false) ), 
        @AttributeOverride(name="seq", column=@Column(name="seq", nullable=false) ) } )
    public ItemBonusId getId() {
        return this.id;
    }
    
    public void setId(ItemBonusId id) {
        this.id = new ItemBonusId();
        this.id = id;
    }
    
    @ManyToOne
    @JoinColumns( { 
        @JoinColumn(name="item_id", referencedColumnName="item_id", nullable=false, insertable=false, updatable=false ), 
        @JoinColumn(name="start_date", referencedColumnName="start_date", nullable=false, insertable=false, updatable=false), 
        @JoinColumn(name="supplier_id", referencedColumnName="supplier_id", nullable=false, insertable=false, updatable=false) } )
    public ItemHpp getItemHpp() {
        return this.itemHpp;
    }
    
    public void setItemHpp(ItemHpp mstItemHpp) {
        this.itemHpp = mstItemHpp;
    }
        
    @Column(name="cara_hitung", length=1)
    public String getCaraHitung() {
        return this.caraHitung;
    }
    
    public void setCaraHitung(String caraHitung) {
        this.caraHitung = caraHitung;
    }
    
    @Column(name="batas")
    public Integer getBatas() {
        return this.batas;
    }
    
    public void setBatas(Integer batas) {
        this.batas = batas;
    }
    
    @Column(name="bonus")
    public Integer getBonus() {
        return this.bonus;
    }
    
    public void setBonus(Integer bonus) {
        this.bonus = bonus;
    }
    
    @Column(name="jenis_bonus", length= 3)
    public String getJenisBonus() {
        return this.jenisBonus;
    }
    
    public void setJenisBonus(String jenisBonus) {
        this.jenisBonus = jenisBonus;
    }
    
    @Temporal(TemporalType.DATE)
    @Column(name="begin_date", length=13)
    public Date getBeginDate() {
        return this.beginDate;
    }
    
    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }
    
    @Temporal(TemporalType.DATE)
    @Column(name="end_date", length=13)
    public Date getEndDate() {
        return this.endDate;
    }
    
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    @ManyToOne()
    @JoinColumn(name="hadiah_id")
    public Hadiah getHadiah() {
        return hadiah;
    }

    public void setHadiah(Hadiah hadiah) {
        this.hadiah = hadiah;
    }
    
    @Column(name="satuan_bonus", length=1)
    public String getSatuanBonus() {
        return satuanBonus;
    }

    public void setSatuanBonus(String SatuanBonus) {
        this.satuanBonus = SatuanBonus;
    }

    public static ItemBonus clone(ItemBonus original) {
        ItemBonus copy = new ItemBonus();
        if (original != null) {
            copy.setId(new ItemBonusId(
                        original.getId().getItemId(), original.getId().getStartDate(), 
                        original.getId().getSupplierId(), original.getId().getSeq()));
            copy.setHadiah(original.getHadiah());
            copy.setSatuanBonus(original.getSatuanBonus());
            copy.setCaraHitung(original.getCaraHitung());
            copy.setBatas(original.getBatas());
            copy.setBonus(original.getBonus());
            copy.setJenisBonus(original.getJenisBonus());
            copy.setBeginDate(original.getBeginDate());
            copy.setEndDate(original.getEndDate());
        }
        return copy;
    }
}


